#include "MemDbg.h"

#include "config.h"
#include "static.h"

#define NOSRC_FILE	"<unknown-file>"

#if MEM_DEBUG

void* operator new(size_t size, const char* src_file, int src_line)
{
	return MEMDBG->AllocMem(size, src_file, src_line);
}

void* operator new[](size_t size, const char* src_file, int src_line)
{
	return MEMDBG->AllocMem(size, src_file, src_line);
}

void* operator new(size_t size)
{
	return MEMDBG->AllocMem(size, NOSRC_FILE, 0);
}

void* operator new[](size_t size)
{
	return MEMDBG->AllocMem(size, NOSRC_FILE, 0);
}

void operator delete(void* ptr, const char* src_file, int src_line)
{
	MEMDBG->FreeMem(ptr, src_file, src_line);
}

void operator delete[](void* ptr, const char* src_file, int src_line)
{
	MEMDBG->FreeMem(ptr, src_file, src_line);
}

void operator delete(void* ptr)
{
	MEMDBG->FreeMem(ptr, NOSRC_FILE, 0);
}

void operator delete[](void* ptr)
{
	MEMDBG->FreeMem(ptr, NOSRC_FILE, 0);
}

#endif //MEM_DEBUG